﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;

namespace UnitTestGetTemperature
{
    [TestClass]
    public class UnitTestGetTemperature
    {
        [TestMethod]
        public void getNumberOfRowsInDb_ShouldNotReturnNegativeInt()
        {
            Plugin.TempSensorThread tst = new Plugin.TempSensorThread();
            int result = tst.getNumberOfRowsInDb();
            Assert.AreNotEqual(-1, result);
        }

        [TestMethod]
        public void getTempsByLimit_WithValidStartValue_ShouldReturnValidList()
        {
            Plugin.TempSensorThread tst = new Plugin.TempSensorThread();
            List<string[]> list = tst.getTempsByLimit(50);
            Assert.IsNotNull(list);
        }

        [TestMethod]
        public void getTempsByLimit_WithNonValidStartValue_ShouldReturnNull()
        {
            Plugin.TempSensorThread tst = new Plugin.TempSensorThread();
            List<string[]> list = tst.getTempsByLimit(-1);
            Assert.IsNull(list);
        }

        [TestMethod]
        public void getTempsOfDay_WithExistingDate_ShouldReturnListWithElements()
        {
            Plugin.TempSensorThread tst = new Plugin.TempSensorThread();
            DateTime date = new DateTime(2011, 12, 04);
            List<string[]> list = tst.getTempsOfDay(date);
            Assert.AreNotEqual(0, list.Count);
        }

        [TestMethod]
        public void getTempsOfDay_WithNonExistingDate_ShouldReturnEmptyList()
        {
            Plugin.TempSensorThread tst = new Plugin.TempSensorThread();
            DateTime date = new DateTime(1755, 01, 01);
            List<string[]> list = tst.getTempsOfDay(date);
            Assert.AreEqual(0, list.Count);
        }
    }
}
